﻿#ifndef SANDBOX_BASIC
#define SANDBOX_BASIC
#include "struct.h"
void init()
{
    /*
     * SandBox Machine init function
     * This function needs to set the reg values.
     * ATTENTION:Since Addr_Regs[Code] begins with 0,command at 0x0000 should be
     * "JMP 0x0200"!
     */
    special_regs[Flag] = RUNNING + ENABLE;       // Init Flags:Running,true mode,interrupt enabled,AVX is off.
    addr_regs[Base] = addr_regs[Stack] = 0xffff; // Init Stack
    addr_regs[Code] = 0x00;
    qword bootloader = 0xa000000000000200;
    // Init RAM
    ram[0] = '\xa0';
    ram[6] = '\x02';
}
void changeFlag(byte reg_var)
{
    special_regs[Flag] &= 0xfffffffffffffcff;
    long long test = static_cast<long long>(*(func_regs + reg_var));
    if (test == 0)
    {
        special_regs[Flag] += 0x100;
        return;
    }
    if (test < 0)
    {
        special_regs[Flag] += 0x200;
        return;
    }
    return;
}

#endif // !SANDBOX_INIT
